import logging


class CustomDebug:

    def __init__(self):

        self.logger = logging.getLogger()
        # 创建一个handler，用于写入日志文件
        # self.fh = logging.FileHandler('test.log', encoding='utf-8')

        # 再创建一个handler，用于输出到控制台
        self.ch = logging.StreamHandler()
        self.formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        # self.fh.setLevel(logging.DEBUG)
        self.ch.setLevel(logging.DEBUG)
        # self.fh.setFormatter(self.formatter)
        self.ch.setFormatter(self.formatter)
        # self.logger.addHandler(self.fh) #logger对象可以添加多个fh和ch对象
        self.logger.addHandler(self.ch)